/**
 *  广告模块整合 20171023
 */
define(function(require,exports,module) {
    var myPub = require('./public');
    // 曝光可视区域元素
    var visualArea = require('./visualAreaInfo');

    var htmlFontSize, intSize, stretchs, stretchLong;
    var resizeTimer = null;

    // 页面尺寸修改
    $(window).on('resize',function() {
        if (resizeTimer) {
            clearTimeout(resizeTimer)
        }
        resizeTimer = setTimeout(function(){
            htmlFontSize = $('html').css('font-size');
            intSize = parseInt(htmlFontSize.split('p')[0]);
            stretchs = 174/26*intSize;
            stretchLong = intSize;
            var oAdvert = $('.jsAdvert');
            var oAdsHRotateBox =  oAdvert.eq(adsAjax.pageIndex).find('.js_AdsHRotateBox');

            oAdsHRotateBox.each(function (i) {
                adsInit.SetAdsRotate(stretchs, oAdsHRotateBox.eq(i), adsAjax.pageIndex);
            });

            var oAdsLong_HScrollSwiper =  oAdvert.eq(adsAjax.pageIndex).find('.js_AdsLong_HScrollBox');
            oAdsLong_HScrollSwiper.each(function (i) {
                adsInit.SetAdsLongSwiper(stretchLong, oAdsLong_HScrollSwiper.eq(i), adsAjax.pageIndex);
            });
        }, 400);
    });

    // var BASE_URL = '';
    var adsInit = {
        time_CutTime: null,             // 倒计时计时器
        time_RunHouse: null,            // 头条计时器
        oSlideAdsScroll: [],            // 横排滚动广告
        oSlideAdsRotate: [],            // 旋转滚动广告
        oSlideAdsLongSwiper: [],        // 长形滚动广告
        oSlideAdsIconSwiper: [],        // icon滚动广告

        // 设置长条滚动广告
        SetAdsLongSwiper: function (stretch, obj, iNow) {
            var _this = this;
            var swiperIndex = obj.index();
            // var oAdsLong_HScrollSwiper = $('.js_AdsLong_HScrollSwiper');
            var oAdsLong_HScrollSwiper = obj.find('.js_AdsLong_HScrollSwiper');
            var isSwiper = null;
            iNow ? iNow : 0;

            if(_this.oSlideAdsLongSwiper[iNow] == undefined) {
                _this.oSlideAdsLongSwiper[iNow] = [];
                _this.oSlideAdsLongSwiper[iNow].swiper = [];
            }

            if(stretch === undefined) {
                var _htmlFontSize = $('html').css('font-size');
                var _intSize = parseInt(_htmlFontSize.split('p')[0]);
                stretch = _intSize;
            }

            if(_this.oSlideAdsLongSwiper[iNow].swiper[swiperIndex] == undefined) {
                AddSwiper(stretch);
            }
            else {
                _this.oSlideAdsLongSwiper[iNow].swiper[swiperIndex].destroy();
                _this.oSlideAdsLongSwiper[iNow].swiper[swiperIndex] = null;
                AddSwiper(stretch);
            }

            function AddSwiper(stretch) {
                isSwiper = oAdsLong_HScrollSwiper.swiper({
                    pagination: null,
                    loop: true,
                    loopAdditionalSlides: 1,
                    // observer: true,
                    // observeParents: true,
                    slidesOffsetBefore: -stretch*0.462,
                    autoplay: 3000,
                    autoplayDisableOnInteraction : false,
                    effect : 'coverflow',
                    slidesPerView: 1.039,
                    centeredSlides: true,
                    coverflow: {
                        rotate: 0,
                        stretch: -stretch,
                        depth: 75,
                        modifier: 4,
                        slideShadows : false
                    },
                    onTouchEnd: function (swiper) {
                        var index = swiper.activeIndex;
                        var _swSlid = oAdsLong_HScrollSwiper.find('.swiper-slide a');
                        var swiper_href = _swSlid.eq(index).attr('swiper_href');
                        if(typeof swiper_href != 'undefined') {
                            _swSlid.removeAttr('href').eq(index).attr('href', swiper_href)
                        }

                        // ddjAction.viewGoods(obj, iNow);
                    }
                });
                _this.oSlideAdsLongSwiper[iNow].swiper[swiperIndex] = isSwiper;
            }

        },

        // 设置旋转滚动广告
        SetAdsRotate:function (stretch, obj, iNow) {
            var _this = this;
            var swiperIndex = obj.index();
            // var oHRotateBox = $('.js_HRotate');
            var oHRotateBox = obj.find('.js_HRotate');
            var oPagin = oHRotateBox.find('.js_pagin');
            var isSwiper = null;
            iNow ? iNow : 0;

            if(_this.oSlideAdsRotate[iNow] == undefined) {
                _this.oSlideAdsRotate[iNow] = [];
                _this.oSlideAdsRotate[iNow].swiper = [];
            }


            if(stretch === undefined) {
                var _htmlFontSize = $('html').css('font-size');
                var _intSize = parseInt(_htmlFontSize.split('p')[0]);
                stretch = 174/26*_intSize;
            }

            if(_this.oSlideAdsRotate[iNow].swiper[swiperIndex] == undefined) {
                AddSwiper(stretch);
            }
            else {
                _this.oSlideAdsRotate[iNow].swiper[swiperIndex].destroy();
                _this.oSlideAdsRotate[iNow].swiper[swiperIndex] = null;
                AddSwiper(stretch);
            }

            function AddSwiper(stretch) {
                isSwiper = oHRotateBox.swiper({
                    pagination: oPagin,
                    loop: true,
                    loopAdditionalSlides: 1,
                    // observer: true,
                    // observeParents: true,
                    roundLengths: true,
                    followFinger:false,
                    autoplay: 3000,
                    autoplayDisableOnInteraction : false,
                    effect : 'coverflow',
                    slidesPerView: 2.14,
                    centeredSlides: true,
                    coverflow: {
                        rotate: 0,
                        stretch: stretch,
                        depth: 200,
                        modifier: 1,
                        slideShadows : false
                    },

                    onTouchEnd: function (swiper) {
                        var index = swiper.activeIndex;
                        var _swSlid = oHRotateBox.find('.swiper-slide a');
                        var swiper_href = _swSlid.eq(index).attr('swiper_href');
                        if(typeof swiper_href != 'undefined'){
                            _swSlid.removeAttr('href').eq(index).attr('href', swiper_href)
                        }
                        // ddjAction.viewGoods(obj, iNow);
                    }


                });
                _this.oSlideAdsRotate[iNow].swiper[swiperIndex] = isSwiper;
            }

        },

        // 设置滚动广告
        SetAdsLiScroll: function (obj, iNow) {
            var _this = this;
            // var oHScrollBox = $('.js_HScroll');
            // var oHScrollBox = obj ? obj.find('.js_HScroll') : $('.js_HScroll');
            var swiperIndex = obj.index();
            var oHScrollBox = obj.find('.js_HScroll');

            var isSwiper = null;
            iNow ? iNow : 0;

            if(_this.oSlideAdsScroll[iNow] == undefined) {
                _this.oSlideAdsScroll[iNow] = [];
                _this.oSlideAdsScroll[iNow].swiper = [];
            }

            if(_this.oSlideAdsScroll[iNow].swiper[swiperIndex] == undefined) {
                AddSwiper();
            }
            else {
                _this.oSlideAdsScroll[iNow].swiper[swiperIndex].destroy();
                _this.oSlideAdsScroll[iNow].swiper[swiperIndex] = null;
                AddSwiper();
            }

            function AddSwiper() {
                isSwiper = oHScrollBox.swiper({
                    freeMode: true,
                    freeModeMomentumRatio: 1,
                    freeModeMomentumVelocityRatio: 1,
                    freeModeMomentumBounce: false,
                    freeModeSticky: true,
                    lazyLoading: true,
                    watchSlidesProgress: true,
                    watchSlidesVisibility : true,
                    slideClass : 'slide-HScroll',
                    slidesPerView : 'auto',
                    onSlideChangeEnd: function (swiper) {
                        // ddjAction.viewGoods(obj, iNow);
                    }
                    // observer: true,
                    // observeParents: true,
                });
                _this.oSlideAdsScroll[iNow].swiper[swiperIndex] = isSwiper ;
            }


        },

        // 设置icon图滚动广告
        SetAdsIconSwiper: function (obj, iNow) {
            var _this = this;
            var swiperIndex = obj.index();
            // var oHScrollBox = $('.js_IconSwiper');
            var oHScrollBox =  obj.find('.js_IconSwiper');

            var isSwiper = null;
            iNow ? iNow : 0;

            if(_this.oSlideAdsIconSwiper[iNow] == undefined) {
                _this.oSlideAdsIconSwiper[iNow] = [];
                _this.oSlideAdsIconSwiper[iNow].swiper = [];
            }

            if(_this.oSlideAdsIconSwiper[iNow].swiper[swiperIndex] == undefined) {
                AddSwiper();
            }
            else {
                _this.oSlideAdsIconSwiper[iNow].swiper[swiperIndex].destroy();
                _this.oSlideAdsIconSwiper[iNow].swiper[swiperIndex] = null;
                AddSwiper();
            }

            function AddSwiper() {
                isSwiper = oHScrollBox.swiper({
                    pagination: ".js_IconSwiperPagination",
                    // lazyLoading: true,
                    // lazyLoadingInPrevNextAmount: 4,
                    watchSlidesProgress: true,
                    watchSlidesVisibility : true,
                    slidesPerView : '5',
                    observer: true,
                    observeParents: true,
                    onTouchEnd: function (swiper) {
                        // ddjAction.viewGoods(obj, iNow);
                    }
                });
                _this.oSlideAdsIconSwiper[iNow].swiper[swiperIndex] = isSwiper;
            }

        },

        // 倒计时
        CutDataTime: function() {
            var _this = this;
            var oActTimeShow = $('.act-timeShow');
            // var oActTimeShow = obj ? obj.find('.act-timeShow') : $('.act-timeShow');
            if(oActTimeShow.length == 0) return;

            var ss = _this.cutTimeToday()%60;
            var mm = ((_this.cutTimeToday() - ss)/60)%60;
            var hh = (_this.cutTimeToday() - _this.cutTimeToday() % 3600)/3600;
            ss = ss < 10 ? ('0' + ss) : ss;
            mm = mm < 10 ? ('0' + mm) : mm;
            hh = hh < 10 ? ('0' + hh) : hh;
            var sHtml = '<span class="timeShow timeBg-black">'+ hh +'</span><i>/</i>'+
                '<span class="timeShow timeBg-black">'+ mm +'</span><i>/</i>'+
                '<span class="timeShow timeBg-red">'+ ss +'</span>';


            oActTimeShow.empty().append(sHtml);
            sHtml = null;
            clearTimeout(_this.time_CutTime);
            _this.time_CutTime = setTimeout(function () {
                _this.CutDataTime()
            }, 1000);

        },

        // 头条跑马灯
        RunHouse: function (obj, iNow) {
            var _this = this;
            // ddjAction.viewGoods(obj, iNow);
            // var oHotMessageUl = $('.js_hotMessage ul');
            var oHotMessageUl = obj ? obj.find('.js_hotMessage ul') : $('.js_hotMessage ul');
            oHotMessageUl.append(oHotMessageUl.html());
            var oHotMessageLI = oHotMessageUl.find('li');
            if(oHotMessageLI.length == 0) return;

            var oLiH = parseInt(oHotMessageLI.outerHeight(true));
            var nLilength = oHotMessageLI.length;
            var disUlTop = 0;

            oHotMessageUl.css({'top': -disUlTop});
            oHotMessageUl.on('touchstart', function () {
                clearTimeout(_this.time_RunHouse);
            });
            oHotMessageUl.on('touchend', function () {
                _this.time_RunHouse = setTimeout(Move,2500)
            });
            Move();
            function Move() {
                if(disUlTop >= oLiH * (nLilength-1) /2) {
                    disUlTop = oLiH;
                    oHotMessageUl.stop().animate({'top': -disUlTop},300);
                } else {
                    disUlTop += oLiH;
                    oHotMessageUl.stop().animate({'top': -disUlTop}, 300, function () {
                        if(disUlTop == oLiH * nLilength/2) {
                            oHotMessageUl.stop().animate({'top': 0},0)
                        }
                    });
                }
                clearTimeout(_this.time_RunHouse);
                _this.time_RunHouse = setTimeout(Move,2500)
            }
        },

        // 当天倒计时
        cutTimeToday: function () {
            var date = new Date();
            date.setMilliseconds(0);

            var nowDate = date.getTime();
            date.setHours(0);
            date.setMinutes(0);
            date.setSeconds(0);
            date.setDate(date.getDate() + 1);
            var nextDay = date.getTime();
            var diffTime = (nextDay - nowDate) / 1000;
            return diffTime
        }
    }
    exports.adsInit = adsInit;

    var adsHtml = {
        // 广告banner  1行一个
        AdsBanner: function (advertItem, iNow) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var shtml = '';
            var adItems = JSON.parse(advertItem.items);
            for (var i=0; i<adItems.length; i++) {
                var item = adItems[i];
                var cLink = _this.GetAdsLink(item.linkType,item.link);
                shtml += '<li><a href="' + cLink + '" data-growing-title="'+advertItem.moduleName+i+'" requestId="'+ advertItem.requestId +'"  goodsid="'+ advertItem.id +'"><img src="' + HTTP_IMAGE_URL + item.imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+i+'" ></a></li>';
            }
            var shtmlBox =
                '<section class="AdsImgShow AdsImgShow js_AdsImgShowBanner">'+
                '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>'+
                '   <div class="AdsImgMain js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">'+
                '       <div class="AdsImgShowBox">'+
                '           <div class="AdsImgShowBanner HBox BoxCenter">' +
                '               <div class="Ads-bannerList Bflex1">' +
                '                   <ul>'+ shtml +'</ul>' +
                '               </div>'+
                '            </div>'+
                '       </div>'+
                '   </div>'+
                '</section>';
            var $shtmlBox = $(shtmlBox);
            if(advertItem.spacing != null && advertItem.spacing == 1){
                $shtmlBox.addClass("AdsInterval_gray")
            }
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($shtmlBox);
            shtml = null;
            shtmlBox = null;
            oSlidePageScroll = null;
            adItems = null;
        },


        // 横排图标滚动广告
        // AdsHorizontal: function (advertItem, iNow) {
        //     var _this = this;
        //     var oSlidePageScroll = $('.js_slidePageScroll');
        //     var shtml = '';
        //     var adItems = JSON.parse(advertItem.items);
        //     for (var i=0; i < adItems.length; i++) {
        //         var item = adItems[i];
        //         var cLink = _this.GetAdsLink(item.linkType,item.link);
        //         shtml +=
        //             '<div class="swiper-slide">' +
        //             '   <a href="' + cLink + '" data-growing-title="'+advertItem.moduleName+i+'">' +
        //             '      <figure>' +
        //             '         <img src="' + HTTP_IMAGE_URL + item.imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+i+'">' +
        //             '      </figure>' +
        //             // '   <aside>'+item.title+'</aside>' +
        //             '    </a>' +
        //             '</div>';
        //     }
        //     var shtmlBox =
        //         '<section class="AdsImgShow AdsInterval_gray ads-hor-finiteScroll">' +
        //         '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>'+
        //         '   <div class="AdsImgMain act-noPadding js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">'+
        //         '       <div class="ads-horList">'+
        //         '           <div class="swiper-container js_IconSwiper">'+
        //         '               <div class="swiper-wrapper">'+
        //                             shtml +
        //         '               </div>' +
        //         '           </div>' +
        //         '           <div class="swiper-pagination js_IconSwiperPagination"></div>'+
        //         '       </div>'+
        //         '   </div>'+
        //         '</section>';
        //     var $shtmlBox = $(shtmlBox);
        //     if(advertItem.spacing != null && advertItem.spacing == 1){
        //         $shtmlBox.addClass("AdsInterval_gray")
        //     }
        //     oSlidePageScroll.eq(iNow).find('.jsAdvert').append($shtmlBox);
        //     adsInit.SetAdsIconSwiper($shtmlBox, iNow);
        //     // 检测图片加载完成后处理
        //     var AdsHorImg =  oSlidePageScroll.eq(iNow).find('.js_IconSwiper img');
        //     var _iNum = 0;
        //     AdsHorImg.hide();
        //     AdsHorImg.each(function (i) {
        //         AdsHorImg[i].onload = function () {
        //             _iNum++;
        //             if(_iNum == AdsHorImg.length) {
        //                 AdsHorImg.parents('figure').css({'height': 'auto'});
        //                 AdsHorImg.show();
        //             }
        //         }
        //     });
        //     // oSlidePageScroll.eq(iNow).find('.js_ads-hor-finite figure').css({'height': 'auto'});
        //     shtml = null;
        //     shtmlBox = null;
        //     oSlidePageScroll = null;
        //     adItems = null;
        // },

        // 横排分类广告
        AdsHorizontal: function (advertItem, iNow) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var shtml = '';
            var adItems = JSON.parse(advertItem.items);
            var shtmlBox = '';
            if (adItems.length < 6) {
                for (var i=0; i < adItems.length; i++) {
                    var item = adItems[i];
                    var cLink = _this.GetAdsLink(item.linkType,item.link);
                    shtml += '<li class="Bflex1">' +
                    '            <a href="' + cLink + '" data-growing-title="'+advertItem.moduleName+i+'">' +
                    '               <figure>' +
                    '                   <img src="' + HTTP_IMAGE_URL + item.imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+i+'">' +
                    '               </figure>' +
                    // '            <aside>'+item.title+'</aside>' +
                    '            </a>' +
                    '          </li>';
                }
                shtmlBox +=
                    '<section class="AdsImgShow ads-hor-finite js_ads-hor-finite">' +
                    '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>'+
                    '   <div class="AdsImgMain js_AdsImgMain" style="background-image: url(' + HTTP_IMAGE_URL + advertItem.backgroundImg + ');background-size: 100% 100%;background-repeat: no-repeat;">'+
                    '       <div class="ads-horList">'+
                    '           <ul class="HBox BoxCenter">'+ shtml + '</ul>' +
                    '       </div>'+
                    '   </div>'+
                    '</section>';
            }else if (adItems.length == 6){
                for (var i=0; i < adItems.length; i++) {
                    var item = adItems[i];
                    var cLink = _this.GetAdsLink(item.linkType,item.link);
                    shtml +=
                        '<div class="swiper-slide">' +
                        '   <a href="' + cLink + '" data-growing-title="'+advertItem.moduleName+i+'" requestId="'+ advertItem.requestId +'" goodsid="'+ advertItem.id +'">' +
                        '      <figure>' +
                        '         <img src="' + HTTP_IMAGE_URL + item.imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+i+'">' +
                        '      </figure>' +
                        // '   <aside>'+item.title+'</aside>' +
                        '    </a>' +
                        '</div>';
                }
                shtmlBox +=
                    '<section class="AdsImgShow ads-hor-finiteScroll">' +
                    '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>'+
                    '   <div class="AdsImgMain act-noPadding js_AdsImgMain" style="background-image: url(' + HTTP_IMAGE_URL + advertItem.backgroundImg + ');background-size: 100% 100%;background-repeat: no-repeat;">'+
                    '       <div class="ads-horList">'+
                    '           <div class="swiper-container js_IconSwiper">'+
                    '               <div class="swiper-wrapper">'+
                    shtml +
                    '               </div>' +
                    '               <div class="swiper-pagination js_IconSwiperPagination"></div>'+
                    '           </div>' +
                    '       </div>'+
                    '   </div>'+
                    '</section>';
            }
            var $shtmlBox = $(shtmlBox);
            if(advertItem.spacing != null && advertItem.spacing == 1){
                $shtmlBox.addClass("AdsInterval_gray")
            }
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($shtmlBox);

            // 检测图片加载完成后处理
            var AdsHorImg =  oSlidePageScroll.eq(iNow).find('.js_ads-hor-finite img');
            var _iNum = 0;
            AdsHorImg.hide();
            AdsHorImg.each(function (i) {
                AdsHorImg[i].onload = function () {
                    _iNum++;
                    if(_iNum == AdsHorImg.length) {
                        AdsHorImg.parents('figure').css({'height': 'auto'});
                        AdsHorImg.show();
                    }
                }
            });
            // oSlidePageScroll.eq(iNow).find('.js_ads-hor-finite figure').css({'height': 'auto'});

            adsInit.SetAdsIconSwiper( $shtmlBox, iNow );
            shtml = null;
            shtmlBox = null;
            adItems = null;

        },

        // 横排分类广告 Min
        AdsHorizontalMin: function (advertItem, iNow) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var shtml = '';
            var adItems = JSON.parse(advertItem.items);
            var shtmlBox = '';
            if (adItems.length < 6) {
            for (var i = 0; i < adItems.length; i++) {
                var item = adItems[i];
                var cLink = _this.GetAdsLink(item.linkType, item.link);
                shtml += '<li class="Bflex1">' +
                    '           <a href="' + cLink + '"data-growing-title="' + advertItem.moduleName + i + '">' +
                    '               <figure>' +
                    '                   <img src="' + HTTP_IMAGE_URL + item.imageUrl + '" alt="" data-growing-title="' + advertItem.moduleName + i + '">' +
                    '               </figure>' +
                    // '                <aside>'+item.title+'</aside>' +
                    '           </a>' +
                    '         </li>';
            }
            shtmlBox +=
                '<section class="AdsImgShow ads-hor-finite js_ads-hor-finite-min act-noPadding">' +
                '   <div class="ads-white-interval" style="background-color: #' + advertItem.topIntervalColor + '"></div>' +
                '   <div class="AdsImgMain js_AdsImgMain" style="background-image: url(' + HTTP_IMAGE_URL + advertItem.backgroundImg + ');background-size: 100% 100%;background-repeat: no-repeat;">' +
                '       <div class="ads-horList-min">' +
                '           <ul class="HBox BoxCenter">' + shtml + '</ul>' +
                '       </div>' +
                '   </div>' +
                '</section>';
            }else if (adItems.length == 6){
                for (var i=0; i < adItems.length; i++) {
                    var item = adItems[i];
                    var cLink = _this.GetAdsLink(item.linkType,item.link);
                    shtml +=
                        '<div class="swiper-slide">' +
                        '   <a href="' + cLink + '" data-growing-title="'+advertItem.moduleName+i+'" requestId="'+ advertItem.requestId +'" goodsid="'+ advertItem.id +'">' +
                        '      <figure>' +
                        '         <img src="' + HTTP_IMAGE_URL + item.imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+i+'">' +
                        '      </figure>' +
                        // '   <aside>'+item.title+'</aside>' +
                        '    </a>' +
                        '</div>';
                }
                shtmlBox +=
                    '<section class="AdsImgShow ads-hor-finiteScroll">' +
                    '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>'+
                    '   <div class="AdsImgMain act-noPadding js_AdsImgMain" style="background-image: url(' + HTTP_IMAGE_URL + advertItem.backgroundImg + ');background-size: 100% 100%;background-repeat: no-repeat;">'+
                    '       <div class="ads-horList">'+
                    '           <div class="swiper-container js_IconSwiper">'+
                    '               <div class="swiper-wrapper">'+
                    shtml +
                    '               </div>' +
                    '           <div class="swiper-pagination js_IconSwiperPagination"></div>'+
                    '           </div>' +
                    '       </div>'+
                    '   </div>'+
                    '</section>';
            }
            var $shtmlBox = $(shtmlBox);
            if(advertItem.spacing != null && advertItem.spacing == 1){
                $shtmlBox.addClass("AdsInterval_gray")
            }
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($shtmlBox);
            // 检测图片加载完成后处理
            var AdsHorImg =  oSlidePageScroll.eq(iNow).find('.js_ads-hor-finite-min img');
            var _iNum = 0;
            AdsHorImg.hide();
            AdsHorImg.each(function (i) {
                AdsHorImg[i].onload = function () {
                    _iNum++;
                    if(_iNum == AdsHorImg.length) {
                        AdsHorImg.parents('figure').css({'height': 'auto'});
                        AdsHorImg.show();
                    }
                }
            });

            adsInit.SetAdsIconSwiper( $shtmlBox, iNow );
            shtml = null;
            shtmlBox = null;
            oSlidePageScroll = null;
            adItems = null;

        },

        // 广告组2个图
        AdsGroup2: function (advertItem, iNow) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var adItems = JSON.parse(advertItem.items);
            if(adItems.length != 2){
                return;
            }
            var cLink0 = _this.GetAdsLink(adItems[0].linkType,adItems[0].link);
            var cLink1 = _this.GetAdsLink(adItems[1].linkType,adItems[1].link);
            var sectionHtml =
                '<section class="AdsImgShow js_AdsGroup2 AdsGroup2">' +
                '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>'+
                '   <div class="AdsImgMain js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">'+
                '       <div class="AdsImgShowBox">' +
                '           <div class="AdsImgShow1-1 HBox">' +
                '               <div class="AdsImg-href-left Bflex1">' +
                '                   <ul class="VBox">' +
                '                       <li class="Bflex1">' +
                '                           <a href="' + cLink0 + '" data-growing-title="'+advertItem.moduleName+0+'" >' +
                '                               <img src="' + HTTP_IMAGE_URL + adItems[0].imageUrl +'" alt=""  data-growing-title="'+advertItem.moduleName+0+'">' +
                '                           </a>' +
                '                       </li>' +
                '                   </ul>' +
                '                </div>' +
                '                <div class="AdsImg-href-right Bflex1 ">' +
                '                   <ul class="VBox">' +
                '                       <li class="Bflex1">' +
                '                           <a href="' + cLink1 + '" data-growing-title="'+advertItem.moduleName+1+'" >' +
                '                               <img src="' + HTTP_IMAGE_URL + adItems[1].imageUrl +'" alt=""  data-growing-title="'+advertItem.moduleName+1+'">' +
                '                           </a>' +
                '                       </li>' +
                '                   </ul>' +
                '               </div>' +
                '           </div>' +
                '       </div>' +
                '   </div>'+
                '</section>';

            var $sectionHtml = $(sectionHtml);
            if(advertItem.spacing != null && advertItem.spacing == 1){
                $sectionHtml.addClass("AdsInterval_gray")
            }
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($sectionHtml);
            sectionHtml = null;
            oSlidePageScroll = null;
            adItems = null;
        },

        // 广告组3个图
        AdsGroup3: function (advertItem, iNow) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var adItems = JSON.parse(advertItem.items);
            if(adItems.length != 3){
                return;
            }
            var cLink0 = _this.GetAdsLink(adItems[0].linkType,adItems[0].link);
            var cLink1 = _this.GetAdsLink(adItems[1].linkType,adItems[1].link);
            var cLink2 = _this.GetAdsLink(adItems[2].linkType,adItems[2].link);
            var sectionHtml =
                '<section class="AdsImgShow AdsImgShow AdsGroup3 js_AdsGroup3">' +
                '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>'+
                '   <div class="AdsImgMain js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">'+
                '       <div class="AdsImgShowBox">' +
                '           <div class="AdsImgShow1-2 HBox">' +
                '               <div class="AdsImg-href-left">' +
                '                   <ul class="VBox">' +
                '                       <li class="Bflex1">' +
                '                           <a href="' + cLink0 + '" data-growing-title="'+advertItem.moduleName+0+'">' +
                '                               <img src="' + HTTP_IMAGE_URL + adItems[0].imageUrl +'" alt=""  data-growing-title="'+advertItem.moduleName+0+'">' +
                '                           </a>' +
                '                       </li>' +
                '                   </ul>' +
                '                </div>' +
                '                <div class="AdsImg-href-right VBox Bflex1 ">' +
                '                   <ul class="VBox Bflex1">' +
                '                       <li class="Bflex1">' +
                '                           <a href="' + cLink1 + '" data-growing-title="'+advertItem.moduleName+1+'">' +
                '                               <img src="' + HTTP_IMAGE_URL + adItems[1].imageUrl +'" alt=""  data-growing-title="'+advertItem.moduleName+1+'">' +
                '                           </a>' +
                '                       </li>' +
                '                       <li class="Bflex1">' +
                '                           <a href="' + cLink2 + '" data-growing-title="'+advertItem.moduleName+2+'">' +
                '                               <img src="' + HTTP_IMAGE_URL + adItems[2].imageUrl +'" alt=""  data-growing-title="'+advertItem.moduleName+2+'">' +
                '                           </a>' +
                '                       </li>' +
                '                   </ul>' +
                '               </div>' +
                '           </div>' +
                '       </div>' +
                '   </div>'+
                '</section>';
            var $sectionHtml = $(sectionHtml);
            if(advertItem.spacing != null && advertItem.spacing == 1){
                $sectionHtml.addClass("AdsInterval_gray")
            }
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($sectionHtml);
            sectionHtml = null;
            oSlidePageScroll = null;
            adItems = null;
        },

        // 广告组5个图
        AdsGroup5: function () {},

        // 今日头条
        AdsHeadline: function (advertItem, iNow) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var boxHtml =
                '<section class="AdsImgShow ads-hotMessage">' +
                '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>'+
                '   <div class="AdsImgMain js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">'+
                '   </div>'+
                '</section>';
            var $htmlBox = $(boxHtml);
            if(advertItem.spacing != null && advertItem.spacing == 1){
                $htmlBox.addClass("AdsInterval_gray")
            }
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($htmlBox);
            var headlineUrl = BASE_URL + "/news/getShowNews";
            G_JSON_POST(headlineUrl,{},function (data) {
                if(data.length <= 0){
                    return;
                }
                var listHtml =
                    '<div class="hotMessage HBox BoxCenter border_top">' +
                    '   <figure>' +
                    '       <img src="' + BASE_URL + '/static_v4/image/icons-ads/icon-ddjads-hotMessage.png" alt="">' +
                    // '    <span class="splitline"></span>' +
                    '   </figure>' +
                    '   <div class="hotMessage-text Bflex1 js_hotMessage">' +
                    '      <ul class="headLineList">' +
                    '      </ul>' +
                    '   </div>' +
                    '</div>';
                var $listHtml = $(listHtml);
                $htmlBox.find('.js_AdsImgMain').append($listHtml);
                var $headlineList = $listHtml.find('.headLineList');
                for (var idx = 0; idx < data.length; idx ++){
                    var item = data[idx];
                    var headlineLi = '';
                    var _href = '';
                    var _typeId = '';
                    var _signHtml = '<span class="iconStyle icon-rob"></span>';
                    // 判断是商品链接还是新闻链接
                    if(item.type == 1) {
                        _href = BASE_URL + '/h/goodspay/goodsView/';
                        _typeId = item.goodsSn;

                    }
                    else {
                        _href = BASE_URL + '/news/detail/';
                    }

                    // 判断是否添加抢购标记
                    // if(item.type == 2) {
                    //     _signHtml = '<span class="iconStyle icon-rob"></span>'；
                    // }

                    headlineLi = '<li><a class="HBox BoxCenter" href="' + _href + _typeId + '" requestId="'+ item.requestId +'">'+ _signHtml +'<span class="Bflex1">' + item.title + '</span></a></li>';

                    $headlineList.append(headlineLi);
                }

                adsInit.RunHouse(oSlidePageScroll.eq(iNow), iNow);

                boxHtml = null;
                listHtml = null;
                oSlidePageScroll = null;
                data = null;

            }, function () {
            }, function () {
            });
        },

        // 1+4
        AdsOneFour: function (advertItem, iNow) {
            var _this = this;
            var adItems = JSON.parse(advertItem.items);
            if(adItems.length == 6){
                var titleImage = HTTP_IMAGE_URL + adItems[0].titleImage;
                var advertHtml = [
                    '<section class="AdsImgShow AdsImgShow AdsGroup1-4">',
                    '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>',
                    '   <div class="AdsImgMain js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">',
                    '	    <!--<div class="goods_title HBox">-->',
                    '	    	<!--<img src="' + titleImage + '" alt="">-->',
                    '	    <!--</div>-->',
                    '	    <!-- 1+4广告  -->',
                    '	    <div class="AdsImgShowBox">',
                    '	    	<div class="AdsImgShow1-4 HBox">',
                    '	    		<div class="AdsImg-href-left">',
                    '	    			<ul class="VBox">',
                    '	    				<li class="Bflex1">' +
                    '                 <a href="' + _this.GetAdsLink(adItems[1].linkType,adItems[1].link) + '" data-growing-title="'+advertItem.moduleName+1+'">' +
                    '                    <img src="' + HTTP_IMAGE_URL + adItems[1].imageUrl + '" alt=""  data-growing-title="'+advertItem.moduleName+1+'">' +
                    '                 </a>' +
                    '             </li>',
                    '	    			</ul>',
                    '	    		</div>',
                    '	    		<div class="AdsImg-href-right VBox Bflex1 ">',
                    '	    			<ul class="VBox Bflex1">',
                    '	    				<li class="Bflex1 HBox">',
                    '	    					<div class="Bflex1 left_Box"><a href="' + _this.GetAdsLink(adItems[2].linkType,adItems[2].link) + '" data-growing-title="'+advertItem.moduleName+2+'">' +
                    '                               <img src="' + HTTP_IMAGE_URL + adItems[2].imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+2+'"></a></div>',
                    '	    					<div class="Bflex1 right_Box"><a href="' + _this.GetAdsLink(adItems[3].linkType,adItems[3].link) + '" data-growing-title="'+advertItem.moduleName+3+'">' +
                    '                               <img src="' + HTTP_IMAGE_URL + adItems[3].imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+3+'"></a></div>',
                    '	    				</li>',
                    '	    				<li class="Bflex1 HBox">',
                    '	    					<div class="Bflex1 left_Box"><a href="' + _this.GetAdsLink(adItems[4].linkType,adItems[4].link) + '" data-growing-title="'+advertItem.moduleName+4+'">' +
                    '                               <img src="' + HTTP_IMAGE_URL + adItems[4].imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+4+'"></a></div>',
                    '	    					<div class="Bflex1 right_Box"><a href="' + _this.GetAdsLink(adItems[5].linkType,adItems[5].link) + '" data-growing-title="'+advertItem.moduleName+5+'">' +
                    '                               <img src="' + HTTP_IMAGE_URL + adItems[5].imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+5+'"></a></div>',
                    '	    				</li>',
                    '	    			</ul>',
                    '	    		</div>',
                    '	    	</div>',
                    '	    </div>',
                    '   </div>',
                    '</section>'].join("");
            }
            else if(adItems.length == 5){
                var titleImage = HTTP_IMAGE_URL + adItems[0].titleImage;
                var advertHtml = [
                    '<section class="AdsImgShow AdsImgShow AdsGroup1-4">',
                    '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>',
                    '   <div class="AdsImgMain js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">',
                    '	    <!--<div class="goods_title HBox">-->',
                    '	    	<!--<img src="' + titleImage + '" alt="">-->',
                    '	    <!--</div>-->',
                    '	    <!-- 1+4广告  -->',
                    '	    <div class="AdsImgShowBox">',
                    '	    	<div class="AdsImgShow1-4 HBox">',
                    '	    		<div class="AdsImg-href-left">',
                    '	    			<ul class="VBox">',
                    '	    				<li class="Bflex1"><a href="' + _this.GetAdsLink(adItems[0].linkType,adItems[0].link) + '" data-growing-title="'+advertItem.moduleName+1+'">' +
                    '                           <img src="' + HTTP_IMAGE_URL + adItems[0].imageUrl + '" alt=""  data-growing-title="'+advertItem.moduleName+0+'"></a></li>',
                    '	    			</ul>',
                    '	    		</div>',
                    '	    		<div class="AdsImg-href-right VBox Bflex1 ">',
                    '	    			<ul class="VBox Bflex1">',
                    '	    				<li class="Bflex1 HBox">',
                    '	    					<div class="Bflex1 left_Box"><a href="' + _this.GetAdsLink(adItems[1].linkType,adItems[1].link) + '" data-growing-title="'+advertItem.moduleName+1+'">' +
                    '                               <img src="' + HTTP_IMAGE_URL + adItems[1].imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+1+'"></a></div>',
                    '	    					<div class="Bflex1 right_Box"><a href="' + _this.GetAdsLink(adItems[2].linkType,adItems[2].link) + '" data-growing-title="'+advertItem.moduleName+2+'">' +
                    '                               <img src="' + HTTP_IMAGE_URL + adItems[2].imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+2+'"></a></div>',
                    '	    				</li>',
                    '	    				<li class="Bflex1 HBox">',
                    '	    					<div class="Bflex1 left_Box"><a href="' + _this.GetAdsLink(adItems[3].linkType,adItems[3].link) + '" data-growing-title="'+advertItem.moduleName+3+'">' +
                    '                               <img src="' + HTTP_IMAGE_URL + adItems[3].imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+3+'"></a></div>',
                    '	    					<div class="Bflex1 right_Box"><a href="' + _this.GetAdsLink(adItems[4].linkType,adItems[4].link) + '" data-growing-title="'+advertItem.moduleName+4+'">' +
                    '                               <img src="' + HTTP_IMAGE_URL + adItems[4].imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+4+'"></a></div>',
                    '	    				</li>',
                    '	    			</ul>',
                    '	    		</div>',
                    '	    	</div>',
                    '	    </div>',
                    '   </div>',
                    '</section>'].join("");
            }
            else {
                return;
            }
            var $advertHtml = $(advertHtml);
            if(advertItem.spacing != null && advertItem.spacing == 1){
                $advertHtml.addClass("AdsInterval_gray")
            }
            var oSlidePageScroll = $('.js_slidePageScroll');
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($advertHtml);
            adItems = null;
            advertHtml = null;
        },

        // 水平滚动产品
        GoodsHScroll: function (advertItem, iNow) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var adItems = JSON.parse(advertItem.items);
            var boxHtml =
                '<div class="AdsImgShow goods_HScroll js_goods_HScroll">' +
                '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>'+
                '   <div class="AdsImgMain js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">'+
                '       <div class="swiper-container goodsBox_HScroll js_HScroll ">' +
                '           <div class="swrap-HScroll swiper-wrapper goodsList js_goodsListScroll" >' +
                '           </div>' +
                '       </div>' +
                '   </div>'+
                '</div>';
            var $htmlBox = $(boxHtml);
            if(advertItem.spacing != null && advertItem.spacing == 1) {
                $htmlBox.addClass("AdsInterval_gray")
            }
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($htmlBox);

            var $goodsList = $htmlBox.find('.js_goodsListScroll');

            /*
             * 使用接口给的新数据
            */

            var data = advertItem.groupGoodsVoList;
            var goodsHtml = '';
            if(data == null || data.length <=0){
                return;
            }
            for (var idx = 0; idx < data.length; idx ++) {
                var item = data[idx];

                // 全额保障  选择性显示哪些右上角图标
                var firstGueeImagePath=item.firstGueeImagePath;
                var html_firstGueeImagePath = '';
                if(firstGueeImagePath!=null && firstGueeImagePath!=""){
                    var gueeUrl=firstGueeImagePath;
                    html_firstGueeImagePath = '<div class="quanpei"><img src="' + gueeUrl + '" alt=""  /></div>';
                }


                // 新品 直降 左上角标记
                var html_goodsLabels = '';
                if(item.goodsLabels && item.goodsLabels != ''){
                    html_goodsLabels =
                        '<div class="verpromotionHot">' +
                        '   <span>'+ item.goodsLabel + '</span>' +
                        '   <div><img src="' + BASE_URL + '/static_v4/image/iconImg/hotIcon.png" alt=""></div>' +
                        '</div>';
                }

                // 好吃 直降 底部提示
                var html_label = ''
                if(item.label && item.label != '') {
                    html_label += '<p class="promotionSale">';
                    for(var i=0;i<item.labels.length;i++){
                        html_label += '<i>'+item.labels[i]+'</i>'
                    }
                    html_label += '</p>';
                }

                goodsHtml +=
                    '<div class="slide-HScroll swiper-slide">' +
                    '   <a href="' + BASE_URL + '/h/goodspay/goodsView/' + item.goodsSn + '" data-growing-title="'+item.name+'" requestId="'+ item.requestId +'" goodsid="'+ item.id +'">' +
                    '       <figure>' +
                    '           <img class="swiper-lazy" data-src="' + HTTP_IMAGE_URL + item.showImage + smallImgArg300 +'" src="' + BASE_URL + '/static_v4/image/loadImg.jpg" data-growing-title="'+item.name+'">'+
                    html_firstGueeImagePath +
                    html_goodsLabels +
                    '       </figure>' +
                    '       <aside class="priceArea VBox Bflex1">' +
                    '           <div class="Bflex1 priceArea_name">' +
                    '               <h4>' + item.name + '</h4>' +
                    '               <div class="smallFont_tip">' + item.title + '</div>' +
                    '               </div>' +
                    '           <div class="priceArea_price">' +
                    '               <div class="HBox priceAreaBox">' +
                    // '                <span class="goodsPriceOld">￥29.00</span>' +
                    '                   <span class="goodsPrice">￥' + item.salePrice + '</span>' +
                    '               </div>' +
                    '           </div>' +
                    html_label +
                    '       </aside>' +
                    '   </a>' +
                    '</div>';
            }

            $goodsList.append(goodsHtml);
            adsInit.SetAdsLiScroll( $htmlBox, iNow );
            boxHtml = null;
            goodsHtml = null;
            item = null;

            // 插入产品标题
            $goodsList.parents('.js_AdsImgMain').prepend(_this.TitleHtml(adItems[0].moduleTitle, adItems[0].timerType));
            adsInit.CutDataTime();


            /*
            * 隐藏以前请求数据操作

            var goodsGroupUrl = BASE_URL + "/shop/goods/loadGoods";
            var data = {groupName:adItems[0].goodsGroupName,start:0,limit:20};
            G_JSON_POST(goodsGroupUrl,data,function (data) {
                var goodsHtml = '';
                if(data.length <= 0){
                    return;
                }
                for (var idx = 0; idx < data.length; idx ++) {
                    var item = data[idx];
                     // 全额保障  选择性显示哪些右上角图标
                    var firstGueeImagePath=item.firstGueeImagePath;
                    var html_firstGueeImagePath = '';
                    if(firstGueeImagePath!=null && firstGueeImagePath!=""){
                        var gueeUrl=firstGueeImagePath;
                        html_firstGueeImagePath = '<div class="quanpei"><img src="' + gueeUrl + '" alt=""  /></div>';
                    }


                    // 新品 直降 左上角标记
                    var html_goodsLabels = '';
                    if(item.goodsLabels && item.goodsLabels != ''){
                        html_goodsLabels =
                            '<div class="verpromotionHot">' +
                                '<span>'+ item.goodsLabel + '</span>' +
                                '<div><img src="' + BASE_URL + '/static_v4/image/iconImg/hotIcon.png" alt=""></div>' +
                            '</div>';
                    }

                    // 好吃 直降 底部提示
                    var html_label = ''
                    if(item.label && item.label != '') {
                        html_label += '<p class="promotionSale">';
                        for(var i=0;i<item.labels.length;i++){
                            html_label += '<i>'+item.labels[i]+'</i>'
                        }
                        html_label += '</p>';
                    }


                    goodsHtml +=
                        '<div class="slide-HScroll swiper-slide">' +
                        '   <a href="' + BASE_URL + '/h/goodspay/goodsView/' + item.goodsSn + '" data-growing-title="'+item.name+'">' +
                        '       <figure>' +
                        '           <img class="swiper-lazy" data-src="' + HTTP_IMAGE_URL + item.showImage + smallImgArg300 +'" src="' + BASE_URL + '/static_v4/image/loadImg.jpg" data-growing-title="'+item.name+'">'+
                                    html_firstGueeImagePath +
                                    html_goodsLabels +
                        '       </figure>' +
                        '       <aside class="priceArea VBox Bflex1">' +
                        '           <div class="Bflex1 priceArea_name">' +
                        '               <h4>' + item.name + '</h4>' +
                        '               <div class="smallFont_tip">' + item.title + '</div>' +
                        '               </div>' +
                        '           <div class="priceArea_price">' +
                        '               <div class="HBox priceAreaBox">' +
                        // '                <span class="goodsPriceOld">￥29.00</span>' +
                        '                   <span class="goodsPrice">￥' + item.salePrice + '</span>' +
                        '               </div>' +
                        '           </div>' +
                                    html_label +
                        '       </aside>' +
                        '   </a>' +
                        '</div>';
                }


                $goodsList.append(goodsHtml);
                adsInit.SetAdsLiScroll( $htmlBox, iNow );
                boxHtml = null;
                goodsHtml = null;
                oSlidePageScroll = null;
                item = null;

            }, function () {
            }, function () {
                // 插入产品标题
                $goodsList.parents('.js_AdsImgMain').prepend(_this.TitleHtml(adItems[0].moduleTitle, adItems[0].timerType));
                adsInit.CutDataTime();
            });
            */


        },

        // 水平滚动产品----拼单--增加查看更多
        GoodsHScrollMore: function (advertItem, iNow) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var adItems = JSON.parse(advertItem.items);
            var boxHtml =
                '<div class="AdsImgShow goods_HScroll js_goods_HScroll">' +
                '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>'+
                '   <div class="AdsImgMain js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">'+
                '       <div class="swiper-container goodsBox_HScroll js_HScroll ">' +
                '           <div class="swrap-HScroll swiper-wrapper goodsList js_goodsListScroll" >' +
                '           </div>' +
                '       </div>' +
                '   </div>'+
                '</div>';
            var $htmlBox = $(boxHtml);
            if(advertItem.spacing != null && advertItem.spacing == 1){
                $htmlBox.addClass("AdsInterval_gray")
            }
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($htmlBox);

            var $goodsList = $htmlBox.find('.js_goodsListScroll');

            /*
             * 使用接口给的新数据

            var datas = advertItem.groupGoodsVoList;
            var goodsHtml = '';
            if(datas == null || datas.length <=0){
                return;
            }
            for (var idx = 0; idx < datas.length; idx ++){
                var item = datas[idx];
                // 全额保障  选择性显示哪些右上角图标
                var firstGueeImagePath=item.firstGueeImagePath;
                var html_firstGueeImagePath = '';
                if(firstGueeImagePath!=null && firstGueeImagePath!="") {
                    var gueeUrl=firstGueeImagePath;
                    html_firstGueeImagePath = '<div class="eightcount"><img src="'+gueeUrl+'" alt="" /></div>';
                }

                // 新品 直降 左上角标记
                var html_goodsLabels = '';
                if(item.goodsLabels && item.goodsLabels != '') {
                    html_goodsLabels =
                        '<div class="verpromotionHot">' +
                        '   <span>'+ item.goodsLabel +'</span>' +
                        '   <div><img src="' + BASE_URL + '/static_v4/image/iconImg/hotIcon.png" alt=""></div>' +
                        '</div>';
                }

                // 好吃 直降 底部提示
                var html_label = '';
                if(item.label && item.label != ''){
                    html_label += '<p class="promotionSale">';
                    for(var i=0;i<item.labels.length;i++){
                        html_label += '<i>'+item.labels[i]+'</i>'
                    }
                    html_label += '</p>';
                }


                goodsHtml += '' +
                    '<div class="slide-HScroll swiper-slide">' +
                    '   <a href="' + BASE_URL + '/h/goodspay/goodsView/' + item.goodsSn + '" data-growing-title="'+item.name+'">' +
                    '       <figure class="pintuan_radius">' +
                    '           <img class="swiper-lazy" data-src="' + HTTP_IMAGE_URL + item.showImage + smallImgArg300 +'" src="' + BASE_URL + '/static_v4/image/loadImg.jpg" data-growing-title="'+item.name+'">' +
                    html_firstGueeImagePath +
                    html_goodsLabels +
                    '       </figure>' +
                    '       <aside class="priceArea VBox Bflex1 collageArea pindanArea">' +
                    '           <div class="Bflex1 priceArea_name">' +
                    '               <h4>' + item.name + '</h4>' +
                    '               <div class="smallFont_tip">' + item.title + '</div>' +
                    '           </div>' +
                    '           <div class="priceArea_price">' +
                    '               <div class="HBox priceAreaBox">' +
                    '                   <span class="goodsPrice">￥' + item.tuangouPrices + '</span>' +
                    '                   <span class="goodsPriceOld goodSalePrice">￥' + item.salePrice + '</span>' +
                    '               </div>' +
                    '           </div>' +
                    html_label +
                    '       </aside>' +
                    '   </a>' +
                    '</div>';
            }
            $goodsList.append(goodsHtml);
            adsInit.SetAdsLiScroll( $htmlBox, iNow );
            boxHtml = null;
            goodsHtml = null;
            item = null;

            // 插入产品标题
            $goodsList.parents('.js_AdsImgMain').prepend(_this.TitleMoreHtml(adItems[0].moduleTitle, adItems[0].timerType,adItems[0].viewMoreUrl));
            adsInit.CutDataTime();
            */


            /*
            隐藏以前请求数据操作
            */

            var goodsGroupUrl = BASE_URL + adItems[0].tuangouGoodsUrl;
            var data = {groupName:adItems[0].goodsGroupName,start:0,limit:20};
            G_JSON_GET(goodsGroupUrl, data, function (data) {
                var datas = data.result;
                var goodsHtml = '';
                if(datas.length <= 0){
                    return;
                }
                for (var idx = 0; idx < datas.length; idx ++) {
                    var item = datas[idx];
                    // 全额保障  选择性显示哪些右上角图标
                    var firstGueeImagePath=item.firstGueeImagePath;
                    var html_firstGueeImagePath = '';
                    if(firstGueeImagePath!=null && firstGueeImagePath!=""){
                        var gueeUrl=firstGueeImagePath;
                        html_firstGueeImagePath = '<div class="eightcount"><img src="'+gueeUrl+'" alt="" /></div>';
                    }

                    // 新品 直降 左上角标记
                    var html_goodsLabels = '';
                    if(item.goodsLabels && item.goodsLabels != ''){
                        html_goodsLabels =
                            '<div class="verpromotionHot">' +
                                '<span>'+ item.goodsLabel +'</span>' +
                                '<div><img src="' + BASE_URL + '/static_v4/image/iconImg/hotIcon.png" alt=""></div>' +
                            '</div>';
                    }

                    // 好吃 直降 底部提示
                    var html_label = '';
                    if(item.label && item.label != ''){
                        html_label += '<p class="promotionSale">';
                        for(var i=0;i<item.labels.length;i++){
                            html_label += '<i>'+item.labels[i]+'</i>'
                        }
                        html_label += '</p>';
                    }


                    goodsHtml += '' +
                        '<div class="slide-HScroll swiper-slide">' +
                        '   <a href="' + BASE_URL + '/h/goodspay/goodsView/' + item.goodsSn + '" data-growing-title="'+item.name+'" requestId="'+ item.requestId +'" goodsid="'+ item.id +'">' +
                        '       <figure class="pintuan_radius">' +
                        '           <img class="swiper-lazy" data-src="' + HTTP_IMAGE_URL + item.showImage + smallImgArg300 +'" src="' + BASE_URL + '/static_v4/image/loadImg.jpg" data-growing-title="'+item.name+'">' +
                                    html_firstGueeImagePath +
                                    html_goodsLabels +
                        '       </figure>' +
                        '       <aside class="priceArea VBox Bflex1 collageArea pindanArea">' +
                        '           <div class="Bflex1 priceArea_name">' +
                        '               <h4>' + item.name + '</h4>' +
                        '               <div class="smallFont_tip">' + item.title + '</div>' +
                        '           </div>' +
                        '           <div class="priceArea_price">' +
                        '               <div class="HBox priceAreaBox">' +
                        '                   <span class="goodsPrice">￥' + item.tuangouPrices + '</span>' +
                        '                   <span class="goodsPriceOld goodSalePrice">￥' + item.salePrice + '</span>' +
                        '               </div>' +
                        '           </div>' +
                                    html_label +
                        '       </aside>' +
                        '   </a>' +
                        '</div>';
                }
                $goodsList.append(goodsHtml);
                adsInit.SetAdsLiScroll( $htmlBox, iNow );
                boxHtml = null;
                goodsHtml = null;
                item = null;

            }, function () {
            }, function () {
                $goodsList.parents('.js_AdsImgMain').prepend(_this.TitleMoreHtml(adItems[0].moduleTitle, adItems[0].timerType,adItems[0].viewMoreUrl));

                adsInit.CutDataTime();
            });



        },

        // 广告图+商品滚动
        AdsAndScroll: function (advertItem, iNow) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var adItems = JSON.parse(advertItem.items);
            if(adItems.length != 1){
                return;
            }
            var item = adItems[0];
            var cLink = _this.GetAdsLink(item.linkType,item.link);
            var adsImg =
                '<section class="AdsImgShow AdsImgShow AdsImgShowBannerScroll js_AdsImgShowBannerScroll">' +
                '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>'+
                '   <div class="AdsImgMain js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">'+
                '       <div class="AdsImgShowBox">'+
                '           <div class="AdsImgShowBanner HBox BoxCenter">' +
                '               <div class="Ads-bannerList Bflex1">' +
                '                   <ul>'+
                '                       <li><a href="' + cLink + '" data-growing-title="'+advertItem.moduleName+'" requestId="'+ advertItem.requestId +'" goodsid="'+ advertItem.id +'"><img src="' + HTTP_IMAGE_URL + item.imageUrl + '" alt="" data-growing-title="'+advertItem.moduleName+'"></a></li>' +
                '                   </ul>' +
                '               </div>'+
                '           </div>'+
                '       </div>' +
                '   </div>'+
                '</section>';


            var goodsScrollBox =
                '<div class="goods_HScroll goods_HScroll-sm js_goods_HScroll">' +
                '   <div class="swiper-container goodsBox_HScroll js_HScroll ">' +
                    '   <div class="swrap-HScroll swiper-wrapper goodsList" >' +
                    '   </div>' +
                '   </div>' +
                '</div>';
            var $scrollBox = $(goodsScrollBox);
            var $adsImg = $(adsImg);
            if(advertItem.spacing != null && advertItem.spacing == 1){
                $adsImg.addClass("AdsInterval_gray")
            }
            $adsImg.find('.js_AdsImgMain').append($scrollBox);
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($adsImg);

            adsImg = null;
            goodsScrollBox = null;

            var $goodsList = $scrollBox.find('.goodsList');

            /*
           * 使用接口给的新数据
           */

            var data = advertItem.groupGoodsVoList;
            if(data == null || data.length <=0) {
                return;
            }
            for (var idx = 0; idx < data.length; idx ++) {
                var item = data[idx];

                // 全额保障  选择性显示哪些右上角图标
                var firstGueeImagePath=item.firstGueeImagePath;
                var html_firstGueeImagePath = '';
                if(firstGueeImagePath!=null && firstGueeImagePath!="") {
                    var gueeUrl=firstGueeImagePath;
                    html_firstGueeImagePath = '<div class="quanpei"><img src="'+gueeUrl+'" alt="" /></div>';
                }

                // 新品 直降 左上角标记
                var html_goodsLabels = '';
                if(item.goodsLabels && item.goodsLabels != '') {
                    html_goodsLabels =
                        '<div class="verpromotionHot">' +
                        '   <span>'+ item.goodsLabel +'</span>' +
                        '   <div><img src="' + BASE_URL + '/static_v4/image/iconImg/hotIcon.png" alt=""></div>' +
                        '</div>';
                }


                // 好吃 直降 底部提示
                var html_label = '';
                if(item.label && item.label != '') {
                    html_label += '<p class="promotionSale">';
                    for(var i=0;i<item.labels.length;i++){
                        html_label += '<i>'+item.labels[i]+'</i>'
                    }
                    html_label += '</p>';
                }

                var goodsHtml =
                    '<div class="slide-HScroll swiper-slide">' +
                    '   <a href="' + BASE_URL + '/h/goodspay/goodsView/' + item.goodsSn + '" data-growing-title="'+item.name+'" requestId="'+ item.requestId +'" goodsid="'+ item.id +'">' +
                    '       <figure>' +
                    '           <img class="swiper-lazy" data-src="' + HTTP_IMAGE_URL + item.showImage + smallImgArg300 +'" src="' + BASE_URL + '/static_v4/image/loadImg.jpg"  data-growing-title="'+item.name+'">' +
                    html_firstGueeImagePath +
                    html_goodsLabels +
                    '       </figure>' +
                    '       <aside class="priceArea VBox Bflex1">' +
                    '           <div class="Bflex1 priceArea_name">' +
                    '               <h4>' + item.name + '</h4>' +
                    '               <div class="smallFont_tip">' + item.title + '</div>' +
                    '           </div>' +
                    '           <div class="priceArea_price">' +
                    '               <div class="HBox priceAreaBox">' +
                    // '                <span class="goodsPriceOld">￥29.00</span>' +
                    '                   <span class="goodsPrice">￥' + item.salePrice + '</span>' +
                    '               </div>' +
                    '           </div>' +
                    html_label +
                    '       </aside>' +
                    '   </a>' +
                    '</div>';
                $goodsList.append(goodsHtml);
                goodsHtml = null;
                item = null;
            }

            adsInit.SetAdsLiScroll( $adsImg, iNow );
        },

        // 商品旋转滚动轮播
        AdsGoodsBanner: function (advertItem, iNow) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var adItems = JSON.parse(advertItem.items);
            if(adItems.length != 1){
                return;
            }
            var item = adItems[0];
            var title = item.moduleTitle;
            var goodsGroupName = item.goodsGroupName;
            var htmlBox = [
                '<section class="AdsImgShow AdsHRotateBox js_AdsHRotateBox">',
                '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>',
                '	<div class="AdsImgMain js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">',
                '	    <div class="goods_title HBox BoxCenter">',
                '	    	<div class="title_line"></div>',
                '	    	<div class="title_name">' + title + '</div>',
                '	    	<div class="title_line"></div>',
                '	    </div>',
                '	    <div class="swiper-container AdsHRotateSwiper js_HRotate">',
                '	    	<div class=" swiper-wrapper goodsList" >',
                '	    	</div>',
                '	    	<div class="swiper-pagination js_pagin "></div>',
                '	    </div>',
                '	</div>',
                '</section>'].join("");
            var $htmlBox = $(htmlBox);

            if(advertItem.spacing != null && advertItem.spacing == 1){
                $htmlBox.addClass("AdsInterval_gray")
            }
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($htmlBox);

            var $goodsList = $htmlBox.find('.goodsList');

            /*
            * 使用接口给的新数据
            */

            var data = advertItem.groupGoodsVoList;
            if(data == null || data.length <=0) {
                return;
            }
            for (var idx = 0; idx < data.length; idx ++){
                var item = data[idx];
                var salePrice = item.salePrice;
                var priceInt = parseInt(salePrice);
                var priceFloat = parseInt((salePrice - priceInt) * 10);
                if(priceFloat == 0){
                    priceFloat = "";
                }else{
                    priceFloat = "." + priceFloat;
                }
                var goodsHtml = [
                    '<div class="swiper-slide goodsList-slide">',
                    '	<a swiper_href="' + BASE_URL + '/h/goodspay/goodsView/' + item.goodsSn + '" data-growing-title="'+item.name+'" requestId="'+ item.requestId +'" goodsid="'+ item.id +'">',
                    '		<figure>',
                    '			<img  src="' + HTTP_IMAGE_URL + item.showImage + smallImgArg300 +'"  data-growing-title="'+item.name+'">',
                    '		</figure>',
                    '		<aside class="priceArea Bflex1">',
                    '			<div class="Bflex1 priceArea_name">',
                    '				<h4>' + item.name + '</h4>',
                    '				<p class="smallFont_tip">' + item.title + '</p>',
                    '			</div>',
                    '			<div class="priceArea_price priceAreaAbs_price">',
                    '				<p class="priceAreaBox">',
                    '					<span class="goodsPrice"><i>￥</i>' + priceInt + '<i>' + priceFloat + '</i></span>',
                    '					<span class="splitline"></span>',
                    '					<span class="topNum">',
                    '					<i>-</i><i>Top' + (idx+1) + '</i><i>-</i>',
                    '				</span>',
                    '				</p>',
                    '			</div>',
                    '		</aside>',
                    '	</a>',
                    '</div>'].join("");

                $goodsList.append(goodsHtml);
                goodsHtml = null;
                item = null;
            }
            adsInit.SetAdsRotate(stretchs, $htmlBox, iNow);
        },

        // 图片滚动轮播
        AdsPicBanner: function (advertItem, iNow) {
            var _this = this;
            var oSlidePageScroll = $('.js_slidePageScroll');
            var adItems = JSON.parse(advertItem.items);
            var picBannerList = "";
            for (var i=0; i < adItems.length; i++) {
                var item = adItems[i];
                var cLink = _this.GetAdsLink(item.linkType,item.link);
                picBannerList += [
                    '<div class="swiper-slide ">',
                    '	<a swiper_href="' + cLink + '" data-growing-title="'+advertItem.moduleName+i+'" requestId="'+ advertItem.requestId +'" goodsid="'+ advertItem.id +'">',
                    '		<figure>',
                    '			<img  src="' + HTTP_IMAGE_URL + item.imageUrl + '"  data-growing-title="'+advertItem.moduleName+i+'">',
                    '		</figure>',
                    '	</a>',
                    '</div>'
                ].join("");
            }
            var htmlBox = [
                '<section class="AdsImgShow AdsLong_HScrollBox js_AdsLong_HScrollBox">',
                '   <div class="ads-white-interval" style="background-color: #'+advertItem.topIntervalColor+'"></div>',
                '	<div class="AdsImgMain js_AdsImgMain" style="background-color: #'+advertItem.backgroundColor+'">',
                '		<div class="swiper-container AdsLong_HScrollSwiper js_AdsLong_HScrollSwiper">',
                '			<div class="swiper-wrapper longSwiper" >',
                picBannerList,
                '			</div>',
                '		</div>',
                '	</div>',
                '</section>'].join("");
            var $htmlBox = $(htmlBox);
            if(advertItem.spacing != null && advertItem.spacing == 1){
                $htmlBox.addClass("AdsInterval_gray")
            }
            oSlidePageScroll.eq(iNow).find('.jsAdvert').append($htmlBox);
            adsInit.SetAdsLongSwiper(stretchLong, $htmlBox, iNow);
            htmlBox = null;
            picBannerList = null;
        },

        GetAdsLink: function (linkType,link) {
            if(linkType == undefined || link == undefined){
                return BASE_URL;
            }
            switch (linkType) {
                case 'CUSTOM_LINK': return link;break;
                case 'H5_LINK': return link;break;
                case 'APP_LINK': return BASE_URL;break;
                case 'GOODS_LINK': return BASE_URL + "/h/goodspay/goodsView/" + link;break;
                default: return BASE_URL;break;

            }
        },

        // 产品标题
        TitleHtml: function (title, timerType) {
            if(title == undefined || title.length <= 0){
                return '';
            }
            var timer = '';
            if(timerType != undefined){
                if(timerType == 'DAY_TIMER'){
                    timer =
                        '<div class="act-timeShow Bflex1">' +
                        '   <span class="timeShow timeBg-black"></span><i>/</i>' +
                        '   <span class="timeShow timeBg-black"></span><i>/</i>' +
                        '   <span class="timeShow timeBg-red"></span>' +
                        '</div>';
                }
            }
            // 标题信息
            var stitleTipText =
                '<div class="goods_title HBox">' +
                '   <h5><span>' + title + '</span>' +
                '   </h5>' +
                '   ' + timer + '' +
                '</div>';
            return stitleTipText;
        },

        // 产品标题增加拼单商品与查看更多链接
        TitleMoreHtml: function (title, timerType,moreUrl) {
            if(title == undefined || title.length <= 0){
                return '';
            }
            var timer = '';
            if(timerType != undefined){
                if(timerType == 'DAY_TIMER'){
                    timer = '<div class="act-timeShow Bflex1">' +
                        '<span class="timeShow timeBg-black"></span><i>/</i>' +
                        '<span class="timeShow timeBg-black"></span><i>/</i>' +
                        '<span class="timeShow timeBg-red"></span></div>';
                }
            }
            // 标题信息
            var stitleTipText =
                '<div class="goods_title HBox">' +
                '   <h5><span>' + title + '</span></h5>' +
                '   ' + timer +
                '   <a class="index_addMore" href="'+moreUrl+'"><span>查看更多</span><i class="iconStyle icon-href-right"></i></a>'+
                '</div>';

            return stitleTipText;
        }

    }
    exports.adsHtml = adsHtml;

    var adsAjax = {
        pageIndex: 0,
        loadAdsCount: 0,                // 加载计数
        categoryNames: [],                // 广告模块名称
        lockScroll: function () {
            var _this = this;
            _this.loadAdsCount ++;
        },

        unlockScroll: function (fn) {
            var _this = this;
            _this.loadAdsCount --;
            if(_this.loadAdsCount == 0) {
                if(fn)fn();
            }
        },

        // 设置广告数据
        AdsAjaxData: function (index, categoryNames, fn) {
            var _this = this;
            _this.categoryNames = categoryNames;
            _this.pageIndex = index;
            var advertUrl = BASE_URL +  "/moduleAdvert/getShowAdvert";
            var data = {};
            if(index != 0){
                data = {"sceneName":categoryNames[index-1]};
            }else{
                if(typeof HOME_SCENE != 'undefined'){
                    data = {"sceneName":HOME_SCENE};
                }
            }
            var _data = null;
            G_JSON_POST(advertUrl,data,function (data) {
                _data = data
                if(data.length <= 0) {
                    if(fn)fn();
                    return;
                }
                for (var idx = 0; idx < data.length; idx ++ ) {
                    var advertItem = data[idx];
                    switch (advertItem.moduleType) {
                        case "NAVIGATION" :
                            adsHtml.AdsHorizontal(advertItem, index);
                            break;
                        case "NAVIGATION_MIN" :
                            adsHtml.AdsHorizontalMin(advertItem, index);
                            break;
                        case "SHOPWINDOW" :
                            adsHtml.AdsGroup3(advertItem, index);
                            break;
                        case "DOUBLEGOODS" :
                            adsHtml.AdsGroup2(advertItem, index);
                            break;
                        case "GOODSSCROLL" :
                            adsHtml.GoodsHScroll(advertItem, index);
                            break;
                        case "SINGLEGOODS" :
                            adsHtml.AdsBanner(advertItem, index);
                            break;
                        case "GOODSGROUP" :
                            adsHtml.AdsAndScroll(advertItem, index);
                            break;
                        case "HEADLINE" :
                            adsHtml.AdsHeadline(advertItem, index);
                            break;
                        case "ONEFOURADVERT" :
                            adsHtml.AdsOneFour(advertItem, index);
                            break;
                        case "BANNER_TYPE_1" :
                            adsHtml.AdsGoodsBanner(advertItem, index);
                            break;
                        case "BANNER_TYPE_2" :
                            adsHtml.AdsPicBanner(advertItem, index);
                            break;
                        case "TUANGOU" :
                            adsHtml.GoodsHScrollMore(advertItem, index);
                            break;
                        // case "BANNER_TYPE_2" :
                        //     adsHtml.AdsHorizontalScroll(advertItem, index);
                        //     break;
                        default:
                            console.error("暂不支持的广告类型 " + advertItem.moduleType);
                            break;

                    }
                }
                if(fn)fn();
            }, function () {
                // start
            }, function () {
                // end
                if(_data == null) {
                    if(fn)fn();
                }
            });
        },

        AdsAjaxDataForRegion: function (index, categoryNames, fn) {
            var _this = this;
            var advertUrl = BASE_URL +  "/moduleAdvert/getShowRegionAdvert";
            var data = {};
            data = {"sceneName":categoryNames};

            G_JSON_POST(advertUrl,data,function (data) {
                if(data.length <= 0){
                    return;
                }
                $(".swiper-wrapper").remove();
                for (var idx = 0; idx < data.length; idx ++ ){
                    var advertItem = data[idx];
                    switch (advertItem.moduleType) {
                        case "NAVIGATION" :
                            adsHtml.AdsHorizontal(advertItem, index);
                            break;
                        case "NAVIGATION_MIN" :
                            adsHtml.AdsHorizontalMin(advertItem, index);
                            break;
                        case "SHOPWINDOW" :
                            adsHtml.AdsGroup3(advertItem, index);
                            break;
                        case "DOUBLEGOODS" :
                            adsHtml.AdsGroup2(advertItem, index);
                            break;
                        case "GOODSSCROLL" :
                            adsHtml.GoodsHScroll(advertItem, index);
                            break;
                        case "SINGLEGOODS" :
                            adsHtml.AdsBanner(advertItem, index);
                            break;
                        case "GOODSGROUP" :
                            adsHtml.AdsAndScroll(advertItem, index);
                            break;
                        case "HEADLINE" :
                            adsHtml.AdsHeadline(advertItem, index);
                            break;
                        case "ONEFOURADVERT" :
                            adsHtml.AdsOneFour(advertItem, index);
                            break;
                        case "BANNER_TYPE_1" :
                            adsHtml.AdsGoodsBanner(advertItem, index);
                            break;
                        case "BANNER_TYPE_2" :
                            adsHtml.AdsPicBanner(advertItem, index);
                            break;
                        case "TUANGOU" :
                            adsHtml.GoodsHScrollMore(advertItem, index);
                            break;
                        // case "BANNER_TYPE_2" :
                        //     adsHtml.AdsHorizontalScroll(advertItem, index);
                        //     break;
                        default:
                            console.error("暂不支持的广告类型 " + advertItem.moduleType);
                            break;

                    }
                }
                if(fn)fn();
            }, function () {
                // start
            }, function () {
                // end
            });
        },

        // 广告数据
        getPop:function () {
            // if(myPub.getCookie('adsLayer') == null) {
            //    G_JSON_GET('/popAdv/getPop',null,function (response) {
            //         try {
            //             var link = response.link, popImage = response.popImage;
            //             if (link != '' && popImage != '') {
            //                 $('#popImage').attr('src', HTTP_IMAGE_URL + popImage)
            //                 $('#popLink').attr('href', link);
            //                 $('.layer_Ads').show();
            //                 myPub.setCookie('adsLayer',true, 's'+adsInit.cutTimeToday());
            //             }
            //         } catch (e) { }
            //     })
            // }
            G_JSON_GET("/popAdv/getPop4", null, function(response) {
                try {
                    if(response!=null&&response!=""){
                        var popAdvMemoryOpt = response.popAdvMemoryOpt;
                        var popImage = response.popImage;
                        var link = response.link;
                        var popId = response.popId;
                        if(popAdvMemoryOpt=='SHOW_ONCE' || popAdvMemoryOpt=='ONCE_DAY_SHOW'){
                            if (myPub.getCookie("adsLayer"+popId) == null){
                                $("#popImage").attr("src", HTTP_IMAGE_URL + popImage);
                                $("#popLink").attr("href", link);
                                $(".layer_Ads").show();
                                myPub.setCookie("adsLayer"+popId, true, "s" + response.popAdvCookieRemainSecond);
                            }
                        }else{
                            $("#popImage").attr("src", HTTP_IMAGE_URL + popImage);
                            $("#popLink").attr("href", link);
                            $(".layer_Ads").show();
                        }

                    }

                } catch (e) {}
            });
        }
    }
    exports.adsAjax = adsAjax;

    // 用户行为
    var ddjAction = {
        viewGoods: function (obj, iNow) {
            var ddjActionPositionId = {};
            ddjActionPositionId.positionFirst = '首页';
            if(iNow > 0) {
                ddjActionPositionId.positionId = 2;
                // ddjActionPositionId.positionType = '首页-' + adsAjax.categoryNames[iNow-1];
                ddjActionPositionId.positionSecond = adsAjax.categoryNames[iNow-1];
            }
            else {
                ddjActionPositionId.positionId = 1;
                // ddjActionPositionId.positionType = '首页-推荐';
                ddjActionPositionId.positionSecond = '推荐';
            }


            // 统计曝光数据
            visualArea.viewEl.showViewEls( obj, function (data, dataJson) {
                ddjhoc.setData(data, 'rec_show', 'add', function () {
                    // console.log('ddjhoc.params.rec_show.adsMod', ddjhoc.params);
                    if( ddjhoc.params.length != 0 ) ddjhoc.sendData( ddjhoc.params );

                    console.log('ddjhoc.ddjParams.rec_show.adsMod', ddjhoc.ddjParams);
                    if( ddjhoc.ddjParams.length != 0 ) ddjhoc.sendDDJData( ddjhoc.ddjParams );
                }, dataJson, ddjActionPositionId);

            });
        }
    }

});